//
//  UnitaryController.m
//  firsttry
//
//  Created by Russ Welti on 5/3/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "UnitaryController.h"

@implementation UnitaryController

-(void)awakeFromNib {
    [fahrenheitTextField setFloatValue:32.0];
    [celsiusTextField setFloatValue:0.0];
		[celsiusTextField setTextColor:[NSColor redColor]];
		//asdfasdf sadf [celsiusTextField setBackgroundColor:[NSColor grayColor]];
		[fahrenheitTextField setTextColor:[NSColor greenColor]];
		//[fahrenheitTextField setBackgroundColor:[NSColor grayColor]];
}

-(IBAction)convert:(id)sender {
    if ( sender == celsiusTextField ) {
        float celsiusTemperature = [celsiusTextField floatValue];
        [fahrenheitTextField setFloatValue:(1.8 * celsiusTemperature + 32.0)];
    }
    else if ( sender == fahrenheitTextField ) {
        float fahrenheitTemperature = [fahrenheitTextField floatValue];
        [celsiusTextField setFloatValue:((fahrenheitTemperature - 32.0) / 1.8)];
    }
}

-(IBAction)showColor:(id) sender {
		float r,g,b,a;
		NSColor *c = [NSColor alloc];
		c = [[colorWell color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
         [c getRed:&r green:&g blue:&b alpha:&a];
		r *= 255.0; g *= 255.0; b *= 255.0;
		NSString *rgba =  [NSString stringWithFormat:@"R: %3.0f  G: %3.0f  B:%3.0f",r,g,b];
		[colorValue setStringValue:rgba];
		[colorValue setTextColor:c];

	    }

@end